#include <iostream>
#include <memory>

class Test
{
public:
    Test()
    {
        std::cout<<"构造函数"<<std::endl;
    }
    ~Test()
    {
        std::cout<<"析构函数"<<std::endl;
    }
};

 
 
void func()
{
    std::unique_ptr<Test> p(new Test);
    Test t2;
    //异常被抛出,函数立即终止,马上返回
    throw 10;
    Test t3;
}


int main()
{
    try
    {
        func();
    }
    catch(int a)
    {
        std::cout<<"捕获异常!"<<std::endl;
    }
}